1. Field of the Invention
Methods and apparatuses consistent with the present invention relate to a method and apparatus for encoding and decoding based on intra prediction, and more particularly, to a method and apparatus which can increase a compression rate of image data encoding by accurately predicting an intra prediction direction of a current block that is to be encoded.
2. Description of the Related Art
In related art methods of image compression, such as MPEG-1, MPEG-2, and MPEG-4H.264/MPEG-4 advanced video coding (AVC), a picture is divided into macro blocks in order to encode an image. Then, each macro block is encoded using inter prediction and intra prediction. The macro blocks are then encoded after selecting a suitable encoding mode by considering data size of the encoded macro block and distortion of the original macro block.
In an intra prediction, a macro block of a current picture is encoded using pixel values spatially adjacent to the current block that is to be encoded, not a reference picture. First, a prediction value of the current block that is to be encoded is calculated using the adjacent pixel values. Then, a difference between the prediction value and a pixel value of the original current block is encoded. Here, intra prediction modes can be largely divided into an intra prediction mode in luminance components and an intra prediction mode in chrominance components. The intra prediction mode in luminance components is divided into a 4×4 intra prediction mode, an 8×8 intra prediction mode, and a 16×16 intra prediction mode.
FIG. 1 illustrates a related art 16×16 intra prediction mode.
Referring to FIG. 1, the 16×16 intra prediction mode includes a total of four modes, i.e., a vertical mode, a horizontal mode, a direct current (DC) mode, and a plane mode.
FIG. 2 illustrates a related art 4×4 intra prediction mode.
Referring to FIG. 2, the 4×4 intra prediction mode includes a total of nine modes, i.e., a vertical mode, a horizontal mode, a DC mode, a diagonal down-left mode, a diagonal down-right mode, a vertical right mode, a vertical left mode, a horizontal-up mode, and a horizontal-down mode.
Prediction mode numbers indexed in each mode are determined based on the frequency with which each mode is used. The vertical mode, i.e., mode 0, is the most frequently used mode while performing intra prediction on a corresponding block, and the horizontal-up mode, i.e., mode 8, is the least used.
Operations of prediction encoding a 4×4 current block using mode 0 of FIG. 2, i.e., the vertical mode, will be described. First, pixel values of pixels A through D, adjacent to the upper part of the 4×4 current block, are predicted as pixel values of the 4×4 current block. That is, the pixel value of pixel A is predicted as four pixel values included in the first column of the 4×4 current block, the pixel value of pixel B is predicted as four pixel values included in the second column of the 4×4 current block, the pixel value of pixel C is predicted as four pixel values included in the third column of the 4×4 current block, and the pixel value of pixel D is predicted as four pixel values included in the fourth column of the 4×4 current block. Next, a difference between the prediction values of the 4×4 current block predicted using pixels A through D and actual values of pixels included in the original 4×4 current block is obtained, and bit-stream of the 4×4 current block is generated by encoding the difference.
In encoding an image according to the H.264 standard, a current macro block is encoded using a total of 13 modes from the 4×4 intra prediction mode and the 16×16 intra prediction mode in order to perform intra prediction encoding using the optimum mode. The optimum mode is selected by considering residue and distortion between the original block and the predicted block.
In order to decode an intra prediction encoded bit stream, a receiver which receives the intra predicted encoded bit stream requires information about an intra prediction direction. Accordingly, the information about the intra prediction direction is inserted into the bit stream and then the bit stream is transmitted to the receiver while intra prediction encoding is performed. When inserting the information about the intra prediction direction into the bit stream, a predetermined encoding method is used in order to reduce the number of bits. Hereinafter, intra prediction encoding according to the H.264 standard will be described.
FIGS. 3A and 3B illustrate a related art method of encoding information about an intra prediction direction. P denotes an intra prediction mode number of a current block 30, A denotes an intra prediction mode number of an upper block 31, and L denotes an intra prediction mode number of a left block 32.
In the intra prediction encoding according to the H.264 standard, information about the intra prediction direction of the current block 30 is encoded by referring to intra prediction directions of the upper block 31, which is adjacent to the upper side of the current block 30, and the left block 32, which is adjacent to the left side of the current block 30. The upper block 31 and the left block 32 are adjacent blocks for which encoding was completed before the current block 30, and have prediction mode numbers which respectively indicate an intra prediction direction.
First, an intra prediction mode number of the current block 30 is compared with a minimum intra prediction mode number from among an intra prediction mode number of the upper block 31 and an intra prediction mode number of the left block 32.
When the minimum intra prediction mode number and the intra prediction mode number of the current block 30 are equal, the intra prediction mode number of the current block 30 is encoded to 1 and inserted into a bit stream. A receiver, upon receiving the bit stream, determines the intra prediction mode number of the current block 30 to be the minimum intra prediction mode number by referring to the intra prediction mode numbers of the upper block 31 and the left block 32, and then performs decoding based on the corresponding intra prediction direction. As described above, a prediction mode number is determined based on the frequency with which each mode is used, and since the current block 30 has a high possibility of having a similar intra prediction direction as the adjacent blocks, the minimum intra prediction mode number from the adjacent blocks and the intra prediction mode number of the current block 30 may be equal. Accordingly, the information about the intra prediction direction of the current block 30 can be expressed in one bit, and the information is compressed accordingly.
When the minimum intra prediction mode number and the intra prediction mode number of the current block 30 are not equal, 0 is inserted into the bit stream. The intra prediction mode number of the current block 30 cannot be determined from the adjacent blocks since the minimum intra prediction mode number and the intra prediction mode number of the current block 30 are not equal. Accordingly, information about the intra prediction direction is inserted as ‘XXX’, i.e., in 3 bits, in the bit stream. There are 9 intra prediction mode numbers, from 0 to 8, and since the above described minimum intra prediction mode number is not the intra prediction mode number of the current block 30, 8 intra prediction mode numbers, excluding the minimum intra prediction mode number, are expressed by 3 bits. In detail, when the minimum intra prediction mode number from the intra prediction mode number of the upper block 31 and the intra prediction mode number of the left block 32 is larger than the intra prediction mode number of the current block 30, binary of the intra prediction mode number of the current block 30 becomes ‘XXX’. However, when the minimum intra prediction mode number is smaller, ‘XXX’ is a binary value obtained by subtracting 1 from the binary value of the intra prediction mode number of the current block 30.
According to a related art technology, when the intra prediction mode number of the current block 30 is equal to the minimum intra prediction mode number of the adjacent blocks, information about the intra prediction direction of the current block 30 can be compressed. However, when the intra prediction mode number of the current block 30 is not equal to the minimum intra prediction mode number, information about the intra prediction direction can be expressed in 4 bits.
Accordingly, when the same direction as the actual intra prediction direction of a current block can be predicted by accurately predicting the intra prediction direction of the current block, the compression rate of image data can be increased.